//
//  HEHealthAssesCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/12/21.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEHealthAssesCell.h"

@interface HEHealthAssesCell ()

@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *descLb;
@property (nonatomic, strong) UIImageView *iconView;

@end

@implementation HEHealthAssesCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = CLightGrayColor;

        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
 
    warp.layer.shadowColor = [UIColor colorWithRed:13/255.0 green:98/255.0 blue:218/255.0 alpha:0.08].CGColor;
    warp.layer.shadowOffset = CGSizeMake(0,5);
    warp.layer.shadowOpacity = 1;
    warp.layer.shadowRadius = 6;
    warp.layer.cornerRadius = 10;
    
    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(15);
        make.right.equalTo(self.contentView).mas_offset(-15);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
    
//    UIImageView *logoView = [UIImageView new];
//    logoView.contentMode = UIViewContentModeScaleAspectFill;
//    logoView.image = IMAGE_NAMED(@"msg_exam");
//    [warp addSubview:logoView];
  
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYFont(18);
    _titleLb.numberOfLines = 0;
    [warp addSubview:_titleLb];
    
    UIImageView *stateView = [UIImageView new];
    stateView.contentMode = UIViewContentModeScaleAspectFill;
    [warp addSubview:stateView];
    _iconView = stateView;
    
    UIImageView *_arrowView = [UIImageView new];
    _arrowView.contentMode = UIViewContentModeScaleAspectFill;
    _arrowView.image = IMAGE_NAMED(@"go_gray");
    [warp addSubview:_arrowView];
    
    [_arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLb);
        make.right.equalTo(warp).mas_offset(-15);
        make.width.mas_offset(8);
        make.height.mas_offset(12);
    }];
    
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLb);
        make.left.equalTo(warp).mas_offset(15);
        make.width.offset(40);
        make.height.offset(40);
    }];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(25);
        make.left.equalTo(_iconView.mas_right).mas_offset(15);
        make.right.equalTo(_arrowView.mas_left).mas_offset(-10);
    }];
  
    //  footer
    UIView *footerTopLine = [UIView new];
    footerTopLine.backgroundColor = CSplitLineColor;
    [warp addSubview: footerTopLine];
    [footerTopLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).offset(15);
        make.left.equalTo(warp).offset(10);
        make.right.equalTo(warp).offset(-10);
        make.height.offset(1);
    }];
    
    _descLb = [UILabel new];
    _descLb.text = @"-";
    _descLb.font = DYBlodFont(16);
    _descLb.textColor = CNavLightBlackColor;
    _descLb.numberOfLines = 0;
    [warp addSubview: _descLb];
    
    [_descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(footerTopLine.mas_bottom).offset(15);
        make.right.equalTo(warp).offset(-15);
        make.left.equalTo(warp).offset(15);
        make.bottom.equalTo(warp.mas_bottom).offset(-15);
    }];
      
}

- (void)setModel:(HEAssesListModel *)model  {
    _model = model;
     
    [_iconView sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:IMAGE_NAMED(@"noImage")];
    _titleLb.text = model.check_name;
    _descLb.text = model.check_desc;
}
 

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
